package com.ja.inquiry.controller;

import com.ja.inquiry.pojo.CreateInquiry;
import com.ja.inquiry.pojo.Inquiry;
import com.ja.inquiry.pojo.InquirySelectVo;
import com.ja.inquiry.pojo.SupplierSelectVo;
import com.ja.inquiry.service.SupplierService;
import com.ja.util.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by 11936 on 2019/4/28.
 */

@RestController
@CrossOrigin
public class SupplierController {
    @Autowired
    private SupplierService supplierService;
    //inquirySheet/see
    @GetMapping("inquirySheet/see")
    public ResultVo queryByIdExamine(@RequestParam("requestForQuotationId")Inquiry inquiry){
        return  supplierService.queryByIdExamine(inquiry
        .getRequestForQuotationId());
    }
    @GetMapping("partner/queryByLegalPerson")
    public ResultVo queryByLegalPerson(Integer legalPersonId){
        return supplierService.queryByLegalPerson(legalPersonId);
    }

    @PostMapping("material/searchPartnerPage")
    public ResultVo searchPartnerPage(@RequestBody SupplierSelectVo supplierSelectVo){
        return supplierService.searchPartnerPage(supplierSelectVo);
    }
    @PostMapping("legalPerson/ofCurrentUser")
    public ResultVo query(@RequestBody InquirySelectVo inquirySelectVo){
        return supplierService.queryPartner(inquirySelectVo.getUserid());
    }
    @PostMapping("inquirySheet/see")
    public ResultVo query11(@RequestBody Inquiry inquiry){
        return supplierService.queryByForQuotationId(inquiry.getRequestForQuotationId());
    }
    //导出
    //1.定义一个导出模板
    //2.从数据库中查询出将要导出的数据
    //3.把从数据库中查询出的数据赋值给导出模板
    //4.对需要转化的数据进行转化
    //5.在浏览器生成一个文件
    @GetMapping("/exportExcel")
    public ResultVo exportExcel(HttpServletResponse resp, String code,String name,Integer count,String currency) throws Exception{
        return supplierService.exportExcel(resp,code,name,count,currency);
    }
}


